home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / util3 / dbeject.lha / dbEject / eject.c < prev    next >
C/C++ Source or Header  |  1995-08-16  |  1KB  |  59 lines

  1. /*
  2.     eject for trackdisk-like devices.
  3. */
  4.  
  5. #include <exec/exec.h>
  6. #include <dos/dos.h>
  7. #include <devices/scsidisk.h>
  8. #include <proto/exec.h>
  9. #include <proto/dos.h>
  10. #include <devices/trackdisk.h>
  11.  
  12. #include <string.h>
  13.  
  14. UBYTE    version[] = "$VER: eject 1.0 (Mittwoch 16-Aug-95  20:57:26) by Daniel Balster";
  15.  
  16. struct IOStdReq *ior;
  17.  
  18. struct {
  19.     STRPTR device;
  20.     ULONG unit;
  21.     ULONG load;
  22.     ULONG unload;
  23. } args = {0};
  24.  
  25. #define TMPL "DEVICE/A,UNIT/A/N,LOAD/S"
  26.  
  27. int main (void)
  28. {
  29.     struct RDArgs *rda;
  30.  
  31.     if (rda = ReadArgs(TMPL,(LONG*)&(args),NULL))
  32.     {
  33.  
  34.     struct MsgPort *mp;
  35.     
  36.     if(mp=CreateMsgPort())
  37.     {
  38.         if(ior=(struct IOStdReq*)CreateIORequest(mp,sizeof(struct IOStdReq)))
  39.         {
  40.             if(!OpenDevice(args.device,*(ULONG*)(args.unit),(struct IORequest*)ior,0))
  41.             {
  42.                 ior->io_Command = TD_EJECT;
  43.                 ior->io_Flags     = IOF_QUICK;
  44.                 ior->io_Length     = args.load ? 0 : 1;
  45.                 DoIO((struct IORequest*)ior);
  46.  
  47.                 CloseDevice((struct IORequest*)ior);
  48.             }
  49.             DeleteIORequest((struct IORequest*)ior);
  50.         }
  51.         DeleteMsgPort(mp);
  52.     }
  53.  
  54.     }
  55.     else PrintFault(IoErr(),0);
  56.     
  57.     return RETURN_OK;
  58. }
  59.